<#import "../tpl/pageTep.ftl" as page>
<@page.pageBase currentMenu="机构管理">
<style>
    /***循环的表单设置***/
    .bui-select .bui-select-input {
        width: 250px;
    }
    hr {
        border-color: #009688;
    }
</style>
<div class="xm-offline">
    <div class="row">
        <div class="panel">
            <div class="panel-header">
                <a href="${basepath}/manage/organize/toList">返回上一级</a>
            </div>
            <div class="panel-body">
                <form id="detailsForm" class="form-horizontal" action="${basepath}/manage/organize/updateJson"
                      method="post">
                    <input type="hidden" class="control-text span-width span10" name="id" value="${e.id!}" id="id">

                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            机构名称：
                        </label>

                        <div class="controls">
                            <input type="text" class="control-text span-width span10" name="name" value="${e.name!}"
                                   disabled="disabled">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            负责人：
                        </label>

                        <div class="controls">
                            <input type="text" class="control-text span-width span10" name="principal"
                                   value="${e.principal!}" disabled="disabled">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            联系电话：
                        </label>

                        <div class="controls">
                            <input type="text" class="control-text span-width span10" name="principalPhone"
                                   value="${e.principalPhone!}" disabled="disabled">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            机构编码：
                        </label>

                        <div class="controls">
                            <input type="text" class="control-text span-width span8" name="id"
                                   disabled="disabled" value="${e.id!}">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            成立时间：
                        </label>

                        <div class="controls">
                            <input type="text" class="control-text span-width span8" name="buildTime"
                                   disabled="disabled" value="${e.buildTime!}">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            入驻日期：
                        </label>

                        <div class="controls">
                            <input type="text" class="tel control-text span-width span10" name="createTime"
                                   value="${e.createTime!}" disabled="disabled">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            所在地区：
                        </label>

                        <div class="controls">
                            <input type="text" class="control-text span-width span2" name="province"
                                   value="${e.province!}" disabled="disabled"/>&nbsp;&nbsp;
                            <input type="text" class="control-text span-width span2" name="city" value="${e.city!}"
                                   disabled="disabled"/>&nbsp;&nbsp;
                            <input type="text" class="control-text span-width span2" name="area" value="${e.area!}"
                                   disabled="disabled"/>&nbsp;&nbsp;
                            <input type="text" class="control-text span-width span10" name="address"
                                   value="${e.address!}" disabled="disabled"/>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            意向服务领域：
                        </label>

                        <div class="controls">
                            <input class="control-text span-width  span6" type="text" name="field"
                                   value="${e.field!}"
                                   disabled="disabled"/>
                        </div>
                    </div>
                    <div class="control-group" id="organization-img">
                        <label class="control-label">
                            <s>*</s>
                            机构图片：
                        </label>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            机构介绍：
                        </label>

                        <div class="controls control-row12" style="height: 350px;initialFrameWidth: 100%;">
                            <textarea type="text" class="input-large" name="content"
                                      id="content">${e.content!}</textarea>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            机构二维码：
                        </label>
                        <img src="/${e.qrCode!}" style="height: 100px;width: 100px;margin:0 0 10px 10px"/>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            机构级别：</label>

                        <div class="controls">
                            <input type="text" class="control-text" name="rank" value=""
                                   disabled="disabled" id="rank"/>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            上级机构：
                        </label>

                        <div class="controls">
                            <input type="text" class="control-text span-width " id="parentID" disabled>
                        </div>
                    </div>
                    <h3 class="offset2">下级机构
                    </h3>
                    <hr/>
                    <input type="hidden" class="control-text span-width " name="subID" id="sub" value="${e.id!}">

                    <div id="subGrid" class="sub-grid"></div>

            </div>
            </form>
        </div>
    </div>
</div>
</div>
<script type="text/javascript">
    //ueditor编辑器不可编辑状态
    var editor = UE.getEditor('content', {
        readonly: true
    });
    var Grid = BUI.Grid;
    var Store = BUI.Data.Store;
    var imagesStore = new Store({});
    var Select = BUI.Select, Data = BUI.Data;
    var editForm = new BUI.Form.Form({
        srcNode: '#detailsForm',
        submitType: 'ajax',
        callback: function (data) {


        }
    }).render();
    //对机构级别的状态做判断塞值到input中
    var rank = "${e.rank!}";
    if (rank == "1") {
        $("#rank").val("A级");
    }
    if (rank == "2") {
        $("#rank").val("B级");
    }
    if (rank == "3") {
        $("#rank").val("C级");
    }
    /*--------------------------上级机构 begin --------------------*/

    /*--------------------------下级列表  begin--------------------*/
    var subColumns = [
        {
            title: '机构名称', dataIndex: 'name', width: '50%'
        }
    ];
    var subStore = new Store({
        url: '${basepath}/manage/organize/selectSubList',
        autoLoad: true,
        params: {
            id: $("#id").val()
        },
        root: 'data'
    });
    var subGrid = new Grid.Grid({
        render: '#subGrid',
        width: '100%',//如果表格使用百分比，这个属性一定要设置
        columns: subColumns,
        idField: 'title',
        store: subStore
    });
    subGrid.render();
    /*--------------------------下级列表  end--------------------*/
    /*--------------------------多张机构图片分割  begin--------------------*/
    var imgArr = "${e.picture!}".split(",");
    var imgHtml = "";
    for (var i = 0; i < imgArr.length; i++) {
        imgHtml += '<img src="${basepath}/' + imgArr[i] + '"/ style="height: 100px;width: 100px;margin:0 0 10px 10px" />';//创建img标签，图片地址赋值src
    }
    document.getElementById("organization-img").innerHTML += imgHtml;
    /*--------------------------多张机构图片分割  end--------------------*/
    function detail() {
        $.ajax({
            type: "POST",
            dataType: "json",
            url: "${basepath}/manage/organize/selectSupList",
            data: {
                id: $("#id").val()
            },
            success: function (data) {
                $("#parentID").val(data.data[0].name);
            }
        });
    }
    detail();
</script>
</@page.pageBase>